package com.itheima.controller;

import com.itheima.pojo.*;
import com.itheima.service.EntifyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RequestMapping("/nurseplan")
@RestController
public class EntifyController {

    @Autowired
    private EntifyService entifyService;


    /***
     * 分页查询
     */
    @GetMapping
    public Resultwo list(EntifyQueryParam entifyQueryParam){
        // ddddd调用Service查询->PageResult
        PageResultwo pageResultwo = entifyService.listwo(entifyQueryParam);
        //响应数据
        return Resultwo.success(pageResultwo);
    }

//    新增
    @PostMapping
    public Resultwo add(@RequestBody Entity entity){
        return Resultwo.success(entifyService.add(entity));

    }

    //    删除
    @DeleteMapping("/delete/{id}")
    public  Resultwo delete(@PathVariable("id") Integer id){
        System.out.println(id);
        return  Resultwo.success(entifyService.delete(id));
    }

//    查询所有
    @GetMapping("/all")
    public Resultwo findAll(){
        return Resultwo.success(entifyService.fandAll());
    }

//    回显
    @GetMapping("/{id}")
    public Resultwo select(@PathVariable("id") Integer id){
        Entity entity = entifyService.select(id);
        return Resultwo.success(entity);

    }

//    修改
    @PutMapping
    public Resultwo update(@RequestBody Entity entity){
        return Resultwo.success(entifyService. update(entity));
    }







}
